﻿using GSM900A.Models;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO.Ports;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;


namespace GSM900A.Views
{
    /// <summary>
    /// MainView.xaml 的交互逻辑
    /// </summary>
    public partial class MainView : UserControl
    {
        /*private bool isSerialPortOpen = false;
        SerialPort serialPort;
        public Logger logger { get; set; }*/
        
        public MainView()
        {
            //logger = new Logger();
            InitializeComponent();
            DataContext = new MainViewModel();
            //GetComCount();
        }
        /*private void GetComCount()
        {
            string[] portNames = SerialPort.GetPortNames();
            foreach (string portName in portNames)
            {
                comPortComboBox.Items.Add(portName);
            }
            if (comPortComboBox.Items.Count > 0)
            {
                comPortComboBox.SelectedIndex = 0;
            }
        }*/
       /* private void openCloseButton_Click(object sender, RoutedEventArgs e)
        {
            string selectedPort = comPortComboBox.SelectedItem as string;
            if (string.IsNullOrEmpty(selectedPort)) 
            {
                logger.WriteLog("请选择有效串口");
                return;
            }
            try
            {
                serialPort = new SerialPort(selectedPort, 9600, Parity.None, 8, StopBits.One);
                serialPort.Open();
                logger.WriteLog($"串口{selectedPort}已打开");
            }
            catch (Exception ex) 
            {
                logger.WriteLog(ex.ToString());
            }
        }*/
    }
}
